package com.qianfeng.smartplatform.utils;

import com.qianfeng.smartplatform.security.BaseUser;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;

public class SecurityUtils {

	public static BaseUser getUser() {
		Authentication auth = SecurityContextHolder.getContext().getAuthentication();
		if (auth != null) {
			Object principal = auth.getPrincipal();
			if (principal instanceof BaseUser)
				return (BaseUser) principal;
		}

		return null;
	}

}
